﻿Public Class FrmrecuperarContraseña

    Private Sub recuperarContraseña_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None

    End Sub

    Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click

    End Sub


    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        FrminiciarSesion.Show()
        Me.Close()
    End Sub

    Private Sub btnEnviar_Click(sender As Object, e As EventArgs) Handles btnEnviar.Click
        Dim correoElectronico As String
        Dim existeCorreo As Boolean

        Dim infousuario As New List(Of String)
        Dim msk As New Label
        correoElectronico = txtxCorreo.Text

        If (correoElectronico.Length > 1) Then
            existeCorreo = objGestorUsuario.comprobarCorreo(correoElectronico)
            If (existeCorreo = True) Then

                infousuario = objGestorUsuario.obtenerInfousuario(correoElectronico)

                enviarCorreo(correoElectronico, infousuario.Item(0).ToString(),
                             infousuario.Item(1).ToString(), infousuario.Item(2).ToString())

                MsgBox("Correo enviado exitosamente, favor revise su bandeja de entrada")
                Me.Hide()
                FrminiciarSesion.Show()
            Else
                msk.Text = "No existe el correo electronico"
                msk.ForeColor = Color.DarkOrange
                msk.Visible = True
                msk.Width = 500
                msk.Location = New Point(panelCorreo.Location.X + 100, panelCorreo.Location.Y + 50)
                panelPrincipal.Controls.Add(msk)
            End If

        Else
            msk.Text = "Campo requerido"
            msk.ForeColor = Color.DarkOrange
            msk.Visible = True
            msk.Width = 500
            msk.Location = New Point(panelCorreo.Location.X + panelCorreo.Width, panelCorreo.Location.Y + 10)
            panelPrincipal.Controls.Add(msk)
        End If
    End Sub


    Public Sub enviarCorreo(pcorreo As String, pnombreUsuario As String, pcarnet As String, pcontrasena As String)
        objGestorUsuario.EnviarCorreo(pcorreo, pnombreUsuario, pcarnet, pcontrasena)
    End Sub

End Class